package com.match.plugin.disruptor.producer;

import com.lmax.disruptor.EventTranslatorOneArg;
import com.lmax.disruptor.RingBuffer;
import com.match.common.model.dto.MatchOrder;

import cn.hutool.core.bean.BeanUtil;

public class OrderProducer {

	private final RingBuffer<MatchOrder> ringBuffer;

	public OrderProducer(RingBuffer<MatchOrder> ringBuffer) {
		this.ringBuffer = ringBuffer;
	}

	private static final EventTranslatorOneArg<MatchOrder, MatchOrder> TRANSLATOR = new EventTranslatorOneArg<MatchOrder, MatchOrder>() {
		@Override
		public void translateTo(MatchOrder event, long sequence, MatchOrder input) {
			BeanUtil.copyProperties(input,event);
		}
	};
 
	public void onData(MatchOrder input) {
		ringBuffer.publishEvent(TRANSLATOR, input);
	}
}
